<?php 
// 返回近几天的日期
function get_some_date($start,$days){
	if(gettype($start)){
		$start = strtotime($start);
	}
	for($i=0;$i<$days;$i++){
		$day[$i] = date('Y-m-d',$start+($i*86400));
	}
	return $day;
}
// 交换变量值
function swap_value($a,$b){
	list($a,$b) = array($b,$a);
}


// 随机生成转化率范围
function get_conver($start,$end,$num){
	for($i=0;$i<$num;$i++){
		$conver[$i] = rand($start*10000,$end*10000)/10000;
	}
	sort($conver);
	return $conver;
}

// 随机产生一个小周期每一天的刷单数
function get_dan_min_cycle($sum){
	for($i=0,$daned=0;$i<7;$i++){
		if($i==6){
			$dans[$i] = (int)$sum-$daned;
			continue;
		}
		$dans[$i] = (int)round($sum * rand(((100/7)-1)*1000,((100/7)+1)*1000)/100000);
		$daned += $dans[$i];
	}
	sort($dans);
	return $dans;
}
// 每一天刷单数
function get_cycle_dan($sum,$num){
	switch ($num) {
		case 7:{
			// 1 = 1
			$dans = get_dan_min_cycle($sum);
		}
			break;
		case 14:{
			// 1 = 0.4 + 0.6
			$dans_1 = get_dan_min_cycle($sum*0.4);
			$dans_2 = get_dan_min_cycle($sum*0.6);
			$dans = array_merge_recursive($dans_1,$dans_2);
			if($dans[6]<$dans[7]){
				list($dans[6],$dans[7]) = array($dans[7],$dans[6]);
			}
		}break;
		case 21:{
			// 1 = 0.31 + 0.33 + 0.36
			$dans_1 = get_dan_min_cycle($sum*0.31);
			$dans_2 = get_dan_min_cycle($sum*0.33);
			$dans_3 = get_dan_min_cycle($sum*0.36);
			$dans = array_merge_recursive($dans_1,$dans_2,$dans_3);
			if($dans[6]<$dans[7]){
				list($dans[6],$dans[7]) = array($dans[7],$dans[6]);
			}
			if($dans[13]<$dans[14]){
				list($dans[13],$dans[14]) = array($dans[14],$dans[13]);
			}
			
		}break;
		case 28:{
			// 1 = 0.21+0.23+0.26+0.28
			$dans_1 = get_dan_min_cycle($sum*0.21);
			$dans_2 = get_dan_min_cycle($sum*0.23);
			$dans_3 = get_dan_min_cycle($sum*0.26);
			$dans_4 = get_dan_min_cycle($sum*0.28);
			$dans = array_merge_recursive($dans_1,$dans_2,$dans_3,$dans_4);
			if($dans[6]<$dans[7]){
				list($dans[6],$dans[7]) = array($dans[7],$dans[6]);
			}
			if($dans[13]<$dans[14]){
				list($dans[13],$dans[14]) = array($dans[14],$dans[13]);
			}
			if($dans[20]<$dans[21]){
				list($dans[20],$dans[21]) = array($dans[21],$dans[20]);
			}
		}break;
		
		default: return false;
			break;
	}
	return $dans;
}